﻿using Project.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Project.DAL;

namespace Project.BLL
{
    public class UsersBll : BaseBLL<Users>
    {
        public override void SetDal()
        {
            Dal = new UsersDal();
        }

        //分页显示用户信息
        public List<Users> GetUsersByPage(int page, int size, string name, out int count) {
            var list = base.Query();//获取数据源
            if (!string.IsNullOrWhiteSpace(name)) {
                list = list.Where(x => x.loginName.Contains(name));
            }
            count = list.Count();
            var data = list.OrderBy(x => x.userID).Skip((page - 1) * size).Take(size);
            return data.ToList();
        }
        //查询用户信息'
        public List<Users> GetUsers(int id) {
            var list = base.Query().Where(x=>x.userID==id);
            return list.ToList();
        }
        //登录
        public Users LoginUsers(string UserName, string pwd) {
            return base.Query().Where(x => x.loginName == UserName && x.loginPwd == pwd).FirstOrDefault();
        }


    }
}
